import { ApiProperty, PickType } from '@nestjs/swagger';
import { IsInt, IsOptional, IsString, MaxLength } from 'class-validator';
import { SurveyType } from './survey.entity';
import { Type } from 'class-transformer';

export class CreateSurveyDto {
  @ApiProperty({ description: '问卷名称', default: null })
  @IsOptional()
  @IsString()
  name: string;

  // 描述
  @ApiProperty({ description: '问卷描述', default: null })
  @IsOptional()
  @IsString()
  @MaxLength(500)
  desc: string;

  // 页面ID
  @ApiProperty({ description: '页面ID', default: null, required: true })
  @IsString()
  pageId: string;

  // 链接
  @ApiProperty({ description: '问卷链接', required: true, default: '' })
  @IsOptional()
  @IsString()
  link: string;

  @ApiProperty({ description: '问卷类型', enum: SurveyType })
  @IsOptional()
  @IsString()
  type: SurveyType;

	@ApiProperty({ description: '问卷状态', default: 1 })
	@IsOptional()
	@IsInt()
	@Type(() => Number)
	status: number;

  @ApiProperty({ description: '租户ID' })
  @IsOptional()
  @IsInt()
  @Type(() => Number)
  tenantId: number;

  @ApiProperty({ description: '疾病分类ID' })
  @IsOptional()
  @IsInt()
  @Type(() => Number)
  diseaseId: number;
}

export class UpdateSurveyDto extends PickType(CreateSurveyDto, ['name', 'desc', 'link', 'diseaseId'] as const) {}
